package com.turing.post.cardmanagement.util;

import java.io.Serializable;
import java.math.BigInteger;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

/**
 * 卡种类变更费率表（CardClassicChangePolicy）
 * 
 * @author zxp
 * @Jan 21, 2013
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "CardClassicChangePolicy")
@IdClass(CardClassicChangePolicy.class)
public class CardClassicChangePolicy implements Serializable {

	// 0 - 固定金额
	public final static String CHANGEPOLICY_FEETYPE_FIX = "0";
	// 1 – 按余额固定比率
	public final static String CHANGEPOLICY_FEETYPE_BALANCE = "1";

	private BigInteger fromClassicId;// (UNI,FK) 原卡类ID
	private BigInteger toClassicId;// (UNI,FK) 目标卡类ID
	private String feeType;// 收费类型 Char（1） Not Null 0 – 固定金额 1 – 按余额固定比率
	private BigInteger fixedFee;// 固定金额 Decimal（16） Not Null 大于等于0
	private Integer fixedFeeRatio;// 固定比率 Number（4） Not Null 默认0，万分率

	public CardClassicChangePolicy() {
		super();
	}

	@Id
	@Column(name = "FROMCLASSICID")
	public BigInteger getFromClassicId() {
		return fromClassicId;
	}

	public void setFromClassicId(BigInteger fromClassicId) {
		this.fromClassicId = fromClassicId;
	}

	@Id
	@Column(name = "TOCLASSICID")
	public BigInteger getToClassicId() {
		return toClassicId;
	}

	public void setToClassicId(BigInteger toClassicId) {
		this.toClassicId = toClassicId;
	}

	@Column(name = "FEETYPE")
	public String getFeeType() {
		return feeType;
	}

	public void setFeeType(String feeType) {
		this.feeType = feeType;
	}

	@Column(name = "FIXEDFEE")
	public BigInteger getFixedFee() {
		return fixedFee;
	}

	public void setFixedFee(BigInteger fixedFee) {
		this.fixedFee = fixedFee;
	}

	@Column(name = "FIXEDFEERATIO")
	public Integer getFixedFeeRatio() {
		return fixedFeeRatio;
	}

	public void setFixedFeeRatio(Integer fixedFeeRatio) {
		this.fixedFeeRatio = fixedFeeRatio;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((getFromClassicId() == null) ? 0 : getFromClassicId()
						.hashCode());
		result = prime
				* result
				+ ((getToClassicId() == null) ? 0 : getToClassicId().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final CardClassicChangePolicy other = (CardClassicChangePolicy) obj;
		if (getFromClassicId() == null) {
			if (other.getFromClassicId() != null)
				return false;
		} else if (!getFromClassicId().equals(other.getFromClassicId()))
			return false;
		if (getToClassicId() == null) {
			if (other.getToClassicId() != null)
				return false;
		} else if (!getToClassicId().equals(other.getToClassicId()))
			return false;
		return true;
	}

}